import axios from 'axios'

const tokenId = 'DEcX7omIPhbyPBVE5JkmDuNb7IAEywfV'
const url = '/acc_cms/user/appuser/user_list.local'
const Vurl = '/acc_cms/user/appuser/v_user_list.test'
const vApplyUrl = '/acc_cms/user/appuser/apply_vuser_list.test'
const VuserGoodTags = 'acc_cms/operation/tag/big_tag_list2.test'
const singleUserUrl = 'acc_cms/user/appuser/user_detail.test'
const freezeUserUrl = 'acc_cms/user/appuser/freeze_user.test'
const cancelFreezeUrl = 'acc_cms/user/appuser/unfreeze_user.test'
const createVuserUrl = 'acc_cms/user/appuser/add_vuser.test'
const fileUploadUrl = 'acc_cms/common/upload/upload_single'
const rejectVapplyUrl = 'acc_cms/user/appuser/refuse_v_apply.test'
const approvedVapplyUrl = 'acc_cms/user/appuser/pass_v_apply.test'
var userService = {
  // 用户列表
  getNormalUserInfo: function (isV, searchParam) {
    var formData = new FormData()
    for (var a in searchParam) {
      formData.append(a, searchParam[a])
    }
    formData.append('token', tokenId)
    return axios({
      'url': isV ? Vurl : url,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 根据id获取用户信息,用户详情查看
  getUserInfoById: function (uId) {
    var formData = new FormData()
    formData.append('token', tokenId)
    formData.append('uid', uId)
    return axios({
      'url': singleUserUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 冻结用户
  freezeUser: function (uid, resonId) {
    var formData = new FormData()
    formData.append('token', tokenId)
    formData.append('uid', uid)
    formData.append('reson_id', resonId)
    return axios({
      'url': freezeUserUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 解冻用户
  cancelFreeze: function (uid) {
    var formData = new FormData()
    formData.append('token', tokenId)
    formData.append('uid', uid)
    return axios({
      'url': cancelFreezeUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 分类下拉选项
  getVuserGoodTags: function () {
    var formData = new FormData()
    formData.append('token', tokenId)
    return axios({
      'url': VuserGoodTags,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 大V用户申请列表
  getVuserApplyInfo: function (searchParam) {
    var formData = new FormData()
    for (var a in searchParam) {
      formData.append(a, searchParam[a])
    }
    formData.append('token', tokenId)
    return axios({
      'url': vApplyUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 新增大V用户
  createVuser: function (param) {
    var formData = new FormData()
    for (var a in param) {
      if (a === 'v_introduction') {
        formData.append('intro', param['v_introduction'])
      } else if (a === 'call_mobile') {
        formData.append('mobile', param['call_mobile'])
      } else {
        formData.append(a, param[a])
      }
    }
    formData.append('token', tokenId)
    return axios({
      'url': createVuserUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 文件上传
  uploadFile: function (param) {
    var formData = new FormData()
    for (var a in param) {
      formData.append(a, param[a])
    }
    return axios({
      'url': fileUploadUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 拒绝大V申请
  rejectVapply: function (uid) {
    var formData = new FormData()
    formData.append('uid', uid)
    formData.append('token', tokenId)
    return axios({
      'url': rejectVapplyUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  },
  // 通过大V申请
  approvedVapply: function (uid) {
    var formData = new FormData()
    formData.append('uid', uid)
    formData.append('token', tokenId)
    return axios({
      'url': approvedVapplyUrl,
      'data': formData,
      'method': 'post',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Accept': '*/*'
      }
    })
  }

}
export default userService
